fix: 멘토 지원서 승인 시 유저 Role 을 Mentor로 승격#639
fix: 멘토 지원서 승인 시 유저 Role 을 Mentor로 승격#639sukangpunch wants to merge 5 commits intosolid-connection:developfrom
Conversation
Walkthrough
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes Suggested reviewers
🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
whqtker
left a comment
There was a problem hiding this comment.
고생하셨습니다 ~!
다만 현재는 siteUser의 role 만 MENTOR 로 변경하는 거 같은데, mentor 엔티티 또한 생성해야 합니다 ! 이후 관련하여 테스트(승인하면 멘토 생성)도 추가해주시면 좋겠습니다 !!
알겠습니다! |
- not null 인 필드에 빈문자열로 값을 채우는 것 보다, null 허용이 더 의미 있다 판단하여 null 을 허용하도록 하였습니다.
- 멘토 생성의 주체가 어드민으로 변경되어 Mentor 도메인의 Mentor 생성 api 를 제거
- 중복 멘토 생성 예외 처리 및 테스트 추가
There was a problem hiding this comment.
Actionable comments posted: 0
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
src/main/java/com/example/solidconnection/mentor/service/MentorMyPageService.java (1)
40-40:⚠️ Potential issue | 🟡 Minor사용하지 않는
mentorApplicationRepository의존성을 제거하세요.
createMentorMyPage메서드가 제거되면서 이 클래스 내에서mentorApplicationRepository를 참조하는 코드가 더 이상 없습니다. 불필요한 의존성은 정리하는 것이 좋습니다.
- import 제거 (15번 줄)
- 필드 주입 제거 (40번 줄)
정리할 코드
-import com.example.solidconnection.mentor.repository.MentorApplicationRepository;private final MentorRepository mentorRepository; private final SiteUserRepository siteUserRepository; private final HostUniversityRepository hostUniversityRepository; private final TermRepository termRepository; - private final MentorApplicationRepository mentorApplicationRepository;
🧹 Nitpick comments (2)
src/main/java/com/example/solidconnection/mentor/domain/Mentor.java (1)
56-68: 생성자의universityId파라미터 타입 불일치에 주의하세요.
- 생성자 파라미터는
Long universityId(박싱 타입, line 60)인데, 필드는long universityId(원시 타입, line 46)입니다.- 만약
null이 전달되면 auto-unboxing 시NullPointerException이 발생합니다.학습된 비즈니스 규칙에 따르면 APPROVED 상태의
MentorApplication은 항상 non-nulluniversityId를 가지므로 현재 흐름에서는 문제가 없지만, 방어적 코딩 관점에서 파라미터 타입을long으로 통일하거나, null 체크를 추가하는 것을 고려해 주세요. Based on learnings, APPROVED 상태의 MentorApplication은 항상 non-null universityId를 가진다는 비즈니스 규칙이 있습니다.💡 파라미터 타입 통일 제안
public Mentor( String introduction, String passTip, long siteUserId, - Long universityId, + long universityId, long termId ) {src/main/java/com/example/solidconnection/admin/service/AdminMentorApplicationService.java (1)
48-67: 멘토 생성 로직이 잘 구현되어 있습니다. 다만 검증 순서를 개선하면 더 안전합니다.현재 흐름:
mentorApplication.approve()(상태 변경) → line 51validateUserCanCreateMentor()(중복 검증) → line 55트랜잭션 롤백으로 인해 실제 데이터 무결성 문제는 없지만,
approve()이전에 모든 사전 검증을 완료하는 것이 방어적 프로그래밍 관점에서 더 안전합니다. 만약 향후approve()내부에 이벤트 발행 등의 부수 효과가 추가된다면, 롤백만으로는 충분하지 않을 수 있습니다.🔄 검증 순서 변경 제안
`@Transactional` public void approveMentorApplication(Long mentorApplicationId) { MentorApplication mentorApplication = mentorApplicationRepository.findById(mentorApplicationId) .orElseThrow(() -> new CustomException(MENTOR_APPLICATION_NOT_FOUND)); - mentorApplication.approve(); SiteUser siteUser = siteUserRepository.findById(mentorApplication.getSiteUserId()) .orElseThrow(() -> new CustomException(USER_NOT_FOUND)); validateUserCanCreateMentor(siteUser.getId()); + mentorApplication.approve(); siteUser.becomeMentor(); Mentor mentor = new Mentor( null, null, siteUser.getId(), mentorApplication.getUniversityId(), mentorApplication.getTermId() ); mentorRepository.save(mentor); }
관련 이슈
작업 내용
어드민에서 멘토 지원서를 승인 할 때, 유저의 Role 을 Mentor 로 승격하도록 기능을 수정하였습니다.
특이 사항
리뷰 요구사항 (선택)